#pragma once

#include "devAddMsgObj.hpp"
#include "devListAckMsgObj.hpp"
#include "devListNotifyMsgObj.hpp"
#include "devReadMsgObj.hpp"
#include "devReadStatMsgObj.hpp"
#include "deviceManager.hpp"
#include "emptyMsgObj.hpp"
#include "msgObj.hpp"

namespace Protocol {
class MsgFactory {
public:
    static std::unique_ptr<MsgObject> create(const std::string &t, const std::string &p, std::shared_ptr<MqttClient> m, std::shared_ptr<DeviceManager> d) {
        if (t.find("dev/") != std::string::npos && t.find("dev/add") != std::string::npos) {
            return std::make_unique<DevAddMsgObject>(m, d);
        } else if (t.find("dev/") != std::string::npos && t.find("/point/get") != std::string::npos) {
            return std::make_unique<DevReadMsgObject>(m, d);
        } else if (t.find("dev/") != std::string::npos && t.find("list/get_ack") != std::string::npos) {
            return std::make_unique<DevListAckMsgObject>(m, d);
        } else if (t.find("dev/") != std::string::npos && t.find("/notify") != std::string::npos) {
            return std::make_unique<DevListNotifyMsgObject>(m, d);
        } else if (t.find("dev/") != std::string::npos && t.find("/state/get") != std::string::npos) {
            return std::make_unique<DeviceReadStatMsgObject>(m, d);
        }

        return std::make_unique<EmptyMsgObject>(m, d);
    }
};
};  // namespace Protocol
